home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -screenplay- / shareware / warpquake / warpquakesrc / vid_amiga.c < prev    next >
C/C++ Source or Header  |  2000-02-29  |  17KB  |  677 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20. // vid_amiga.c -- amiga video driver
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <signal.h>
  25.  
  26. #include <exec/exec.h>
  27. #include <graphics/gfx.h>
  28. #include <intuition/intuition.h>
  29. #include <libraries/asl.h>
  30. #include <cybergraphics/cybergraphics.h>
  31. #include <utility/tagitem.h>
  32.  
  33. #include <clib/chunkyppc_protos.h>
  34. #include <powerup/ppcproto/exec.h>
  35. #include <powerup/ppcproto/graphics.h>
  36. #include <powerup/ppcproto/intuition.h>
  37. #include <powerup/ppcproto/asl.h>
  38.  
  39. #include "quakedef.h"
  40. #include "d_local.h"
  41.  
  42. #ifdef PPC
  43. extern void ppc_c2p_line (int line, int src, struct BitMap *dst, int cnt);
  44. #endif
  45.  
  46. extern qboolean using_mouse;
  47. extern short int last_mouse[2];
  48. qboolean mousemove = false;
  49. qboolean fastaga = false;
  50. qboolean force = false;
  51. qboolean nodb = false;
  52. qboolean wpa8 = false;
  53.  
  54. #define    BASEWIDTH    320
  55. #define    BASEHEIGHT    200
  56.  
  57. pixel_t *vid_buffer;
  58. short *zbuffer;
  59. byte *surfcache;
  60.  
  61. unsigned short    d_8to16table[256];
  62.  
  63. /**********************************************************************/
  64.  
  65. struct GfxBase *GfxBase = NULL;
  66. struct IntuitionBase *IntuitionBase = NULL;
  67. struct Library *ChunkyPPCBase = NULL;
  68. struct Library *AslBase = NULL;
  69.  
  70. static struct ScreenBuffer *sbuffer[3] = {NULL, NULL, NULL};
  71. static struct ScreenBuffer *nextsbuffer = NULL;
  72. static struct Mode_Screen ms;
  73. struct Mode_Screen *msptr = &ms;
  74. static struct Screen *video_screen = NULL;
  75. static struct Window *video_window = NULL;
  76. static struct ScreenModeRequester *smr = NULL;
  77. static struct RastPort rp;
  78. static struct RastPort temprp;
  79. static struct BitMap *next_bm;
  80. static unsigned char *next_sbuf;
  81. static struct BitMap tmp_bm = {
  82.   0, 0, 0, 0, 0, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
  83. };
  84.  
  85. static UWORD *emptypointer = NULL;
  86. static BOOL is_cyber_mode = FALSE;
  87. static BOOL is_native_mode = FALSE;
  88.  
  89. /**********************************************************************/
  90. void    VID_SetPalette (unsigned char *palette)
  91. {
  92.   int i;
  93.   ULONG v;
  94.   static ULONG colourtable[1+3*256+1];
  95.  
  96.   colourtable[0] = (256 << 16) + 0;
  97.   for (i = 0; i < 3*256; i++) {
  98.     v = *palette++;
  99.     v += (v << 8);
  100.     v += (v << 16);
  101.     colourtable[i+1] = v;
  102.   }
  103.   colourtable[1 + 3*256] = 0;
  104.     if ((fastaga) || (wpa8))
  105.         LoadRGB32 (&video_screen->ViewPort, colourtable);
  106.     else
  107.       LoadColors (&ms, colourtable);
  108. }
  109.  
  110. /**********************************************************************/
  111. void    VID_ShiftPalette (unsigned char *palette)
  112. {
  113.   VID_SetPalette (palette);
  114. }
  115.  
  116. /****************************************************************************/
  117. void    VID_Init (unsigned char *palette)
  118. {
  119.   int mode, d;
  120.     int width = 0, height = 0;
  121.     ULONG idcmp, flags, propertymask;
  122.     struct TagItem stags[7];
  123.     struct TagItem wtags[8];
  124.     struct TagItem atags[12];
  125.  
  126.     fastaga = COM_CheckParm ("-aga");
  127.     force = COM_CheckParm ("-force");
  128.     nodb = COM_CheckParm ("-nodb");
  129.     wpa8 = COM_CheckParm ("-wpa8");
  130.  
  131.     if ((!fastaga) && (!wpa8))
  132.         ChunkyPPCBase = OpenLibrary("chunkyppc.library", 3);
  133.  
  134.     (struct Library *)GfxBase = OpenLibrary("graphics.library", 39);
  135.  
  136.     (struct Library *)IntuitionBase = OpenLibrary("intuition.library", 39);
  137.  
  138.     AslBase = OpenLibrary("asl.library", 38);
  139.  
  140.     if ((!fastaga) && (!wpa8))
  141.     {
  142.         if (ChunkyPPCBase == NULL)
  143.             Sys_Error ("Can't open chunkyppc.library V3\n");
  144.     }
  145.  
  146.     if (GfxBase == NULL)
  147.         Sys_Error ("Can't open graphics.library V39\n");
  148.  
  149.     if (IntuitionBase == NULL)
  150.         Sys_Error ("Can't open intuition.library V39\n");
  151.  
  152.     if ((AslBase = OpenLibrary ("asl.library", 38L)) == NULL ||
  153.       (smr = AllocAslRequest (ASL_ScreenModeRequest, NULL)) == NULL)
  154.     Sys_Error ("OpenLibrary(""asl.library"", 38) failed");
  155.  
  156.     if ((fastaga) || (wpa8))
  157.     {
  158.         if (fastaga)
  159.             is_native_mode = TRUE;
  160.  
  161.         propertymask = DIPF_IS_EXTRAHALFBRITE | DIPF_IS_DUALPF | DIPF_IS_PF2PRI |
  162.                                      DIPF_IS_HAM;
  163.  
  164.         atags[0].ti_Tag = ASLSM_TitleText;
  165.         atags[0].ti_Data = (ULONG)"WarpQuake";
  166.         atags[1].ti_Tag = ASLSM_MinWidth;
  167.         atags[1].ti_Data = BASEWIDTH;
  168.         atags[2].ti_Tag = ASLSM_MinHeight;
  169.         atags[2].ti_Data = BASEHEIGHT;
  170.         atags[3].ti_Tag = ASLSM_InitialDisplayWidth;
  171.         atags[3].ti_Data = BASEWIDTH;
  172.         atags[4].ti_Tag = ASLSM_InitialDisplayHeight;
  173.         atags[4].ti_Data = BASEHEIGHT;
  174.         atags[5].ti_Tag = ASLSM_MinDepth;
  175.         atags[5].ti_Data = 8;
  176.         atags[6].ti_Tag = ASLSM_MaxDepth;
  177.         atags[6].ti_Data = 8;
  178.         atags[7].ti_Tag = ASLSM_DoWidth;
  179.         atags[7].ti_Data = TRUE;
  180.         atags[8].ti_Tag = ASLSM_DoHeight;
  181.         atags[8].ti_Data = TRUE;
  182.         atags[9].ti_Tag = ASLSM_PropertyMask;
  183.         atags[9].ti_Data = propertymask;
  184.         atags[10].ti_Tag = ASLSM_PropertyFlags;
  185.         atags[10].ti_Data = 0;
  186.         atags[11].ti_Tag = TAG_DONE;
  187.         atags[11].ti_Data = 0;
  188.  
  189.         if((AslRequest (smr, atags)) == NULL)
  190.             Sys_Error ("AslRequest() failed\n");
  191.  
  192.         mode = smr->sm_DisplayID;
  193.         width = smr->sm_DisplayWidth;
  194.         height = smr->sm_DisplayHeight;
  195.  
  196.         stags[0].ti_Tag = SA_Type;
  197.         stags[0].ti_Data = CUSTOMSCREEN;
  198.         stags[1].ti_Tag = SA_DisplayID;
  199.         stags[1].ti_Data = mode;
  200.         stags[2].ti_Tag = SA_Width;
  201.         stags[2].ti_Data = width;
  202.         stags[3].ti_Tag = SA_Height;
  203.         stags[3].ti_Data = height;
  204.         stags[4].ti_Tag = SA_Depth;
  205.         stags[4].ti_Data = 8;
  206.         stags[5].ti_Tag = SA_Quiet;
  207.         stags[5].ti_Data = TRUE;
  208.         stags[6].ti_Tag = TAG_END;
  209.         stags[6].ti_Data = 0;
  210.  
  211.         if((video_screen = OpenScreenTagList (NULL, stags)) == NULL)
  212.             Sys_Error ("OpenScreenTagList() failed\n");
  213.  
  214.         idcmp = IDCMP_RAWKEY;
  215.         flags = WFLG_ACTIVATE | WFLG_BORDERLESS | WFLG_NOCAREREFRESH |
  216.               WFLG_SIMPLE_REFRESH;
  217.       if (using_mouse)
  218.         {
  219.         idcmp |= IDCMP_MOUSEBUTTONS | IDCMP_DELTAMOVE | IDCMP_MOUSEMOVE;
  220.         flags |= WFLG_RMBTRAP | WFLG_REPORTMOUSE;
  221.       }
  222.  
  223.         wtags[0].ti_Tag = WA_Left;
  224.         wtags[0].ti_Data = 0;
  225.         wtags[1].ti_Tag = WA_Top;
  226.         wtags[1].ti_Data = 0;
  227.         wtags[2].ti_Tag = WA_Width;
  228.         wtags[2].ti_Data = width;
  229.         wtags[3].ti_Tag = WA_Height;
  230.         wtags[3].ti_Data = height;
  231.         wtags[4].ti_Tag = WA_IDCMP;
  232.         wtags[4].ti_Data = idcmp;
  233.         wtags[5].ti_Tag = WA_Flags;
  234.         wtags[5].ti_Data = flags;
  235.         wtags[6].ti_Tag = WA_CustomScreen;
  236.         wtags[6].ti_Data = (ULONG) video_screen;
  237.         wtags[7].ti_Tag = TAG_DONE;
  238.         wtags[7].ti_Data = 0;
  239.  
  240.         if((video_window = OpenWindowTagList (NULL, wtags)) == NULL)
  241.             Sys_Error ("OpenWindowTagList() failed\n");
  242.  
  243.         if ((emptypointer = AllocVec (16, MEMF_CHIP | MEMF_CLEAR)) == NULL)
  244.             Sys_Error ("Couldn't allocate chip memory for pointer");
  245.         SetPointer (video_window, emptypointer, 1, 16, 0, 0);
  246.  
  247.         InitRastPort (&rp);
  248.         rp.BitMap = video_screen->ViewPort.RasInfo->BitMap;
  249.  
  250.         if (wpa8)
  251.         {
  252.             InitBitMap (&tmp_bm, 8, width, 1);
  253.             for (d = 0; d < 8; d++)
  254.                 if ((tmp_bm.Planes[d] = (PLANEPTR)AllocRaster (width, 1)) == NULL)
  255.                     Sys_Error ("AllocRaster() failed");
  256.             temprp = *video_window->RPort;
  257.             temprp.Layer = NULL;
  258.             temprp.BitMap = &tmp_bm;
  259.         }
  260.  
  261.         if ((!nodb) && (!wpa8))
  262.         {
  263.             if (((sbuffer[0] = AllocScreenBuffer (video_screen, NULL, SB_SCREEN_BITMAP)) == NULL) |
  264.             ((sbuffer[1] = AllocScreenBuffer (video_screen, NULL, NULL)) == NULL ||
  265.             (sbuffer[2] = AllocScreenBuffer (video_screen, NULL, NULL)) == NULL))
  266.           Sys_Error ("AllocScreenBuffer() failed");
  267.         nextsbuffer = sbuffer[1];
  268.             rp.BitMap = nextsbuffer->sb_BitMap;
  269.         }
  270.     }
  271.     else
  272.     {
  273.         ms.SCREENWIDTH = BASEWIDTH;
  274.         ms.SCREENHEIGHT = BASEHEIGHT;
  275.         ms.MS_MAXWIDTH = 1600;
  276.         ms.MS_MAXHEIGHT = 1200;
  277.         ms.MAXDEPTH = 8;
  278.         ms.MINDEPTH = 8;
  279.         ms.video_screen = 0;
  280.         ms.video_window = 0;
  281.  
  282.         if (force)
  283.             msptr = OpenGraphics ("WarpQuake", &ms, 1);
  284.         else
  285.             msptr = OpenGraphics ("WarpQuake", &ms, 0);
  286.  
  287.         if (!msptr)
  288.             Sys_Error ("OpenGraphics() failed\n");
  289.  
  290.         if (!(ChunkyInit(&ms,PIXFMT_LUT8)))
  291.             Sys_Error ("ChunkyInit() failed\n");
  292.  
  293.         if (ms.video_is_native_mode)
  294.         {
  295.             is_native_mode = TRUE;
  296.             if (ms.numbuffers == 1)
  297.                 next_bm = ms.bitmapa;
  298.             else
  299.                 next_bm = ms.bitmapb;
  300.         }
  301.         else
  302.         {
  303.             if (ms.video_is_cyber_mode)
  304.                 is_cyber_mode = TRUE;
  305.             if (ms.numbuffers == 1)
  306.                 next_sbuf = ms.screen;
  307.             else
  308.                 next_sbuf = ms.screenb;
  309.         }
  310.  
  311.       mode = ms.mode;
  312.       width = ms.SCREENWIDTH;
  313.       height = ms.SCREENHEIGHT;
  314.         video_window = ms.video_window;
  315.  
  316.       Con_Printf ("Screen Mode $%08x is", mode);
  317.       if (is_native_mode)
  318.         Con_Printf (" NATIVE-PLANAR");
  319.       else
  320.         Con_Printf (" FOREIGN");
  321.       Con_Printf (" 8-BIT");
  322.       if (is_cyber_mode)
  323.         Con_Printf (" CYBERGRAPHX");
  324.       Con_Printf (", using size %d x %d\n", width, height);
  325.  
  326.         if (!using_mouse)
  327.         {
  328.             if(!(ModifyIDCMP(ms.video_window, IDCMP_RAWKEY)))
  329.                 Sys_Error ("ModifyIDCMP() failed\n");
  330.         }
  331.     }
  332.  
  333.   if ((vid_buffer = (pixel_t *)malloc(sizeof(pixel_t) *
  334.                                       width * height)) == NULL ||
  335.       (zbuffer = (short *)malloc(sizeof(short) * width * height)) == NULL ||
  336.       (surfcache = (byte *)malloc(sizeof(byte) *
  337.                                   (width*height/(320*200))*256*1024*2)) == NULL)
  338.             Sys_Error ("Out of memory");
  339.  
  340.   vid.width = vid.conwidth = width;
  341.   vid.height = vid.conheight = height;
  342.   vid.maxwarpwidth = WARP_WIDTH;
  343.   vid.maxwarpheight = WARP_HEIGHT;
  344.   vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
  345.     if (wpa8)
  346.         vid.numpages = 1;
  347.     else if (fastaga)
  348.         if (nodb)
  349.             vid.numpages = 1;
  350.         else
  351.             vid.numpages = 3;
  352.     else
  353.       vid.numpages = ms.numbuffers;
  354.   vid.colormap = host_colormap;
  355.   vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
  356.   vid.buffer = vid.conbuffer = vid_buffer;
  357.   vid.rowbytes = vid.conrowbytes = width;
  358.   vid.direct = NULL;
  359.  
  360.   d_pzbuffer = zbuffer;
  361.   D_InitCaches (surfcache, sizeof(byte) *
  362.                            (width*height/(320*200))*256*1024*2);
  363.  
  364.   VID_SetPalette (palette);
  365.  
  366. }
  367.  
  368. /**********************************************************************/
  369. void    VID_Shutdown (void)
  370. {
  371.     int d;
  372.  
  373. //  printf ("VID_Shutdown\n");
  374.   if (surfcache != NULL)
  375.     {
  376.     free (surfcache);
  377.     surfcache = NULL;
  378.   }
  379.  
  380.   if (zbuffer != NULL)
  381.     {
  382.     free (zbuffer);
  383.     zbuffer = NULL;
  384.   }
  385.  
  386.   if (vid_buffer != NULL)
  387.     {
  388.     free (vid_buffer);
  389.     vid_buffer = NULL;
  390.   }
  391.  
  392.     if (sbuffer[0] != NULL)
  393.     {
  394.         ChangeScreenBuffer (video_screen, sbuffer[0]);
  395.     WaitTOF ();
  396.     WaitTOF ();
  397.         FreeScreenBuffer (video_screen, sbuffer[0]);
  398.         sbuffer[0] = NULL;
  399.     }
  400.  
  401.     if (sbuffer[1] != NULL)
  402.     {
  403.         FreeScreenBuffer (video_screen, sbuffer[1]);
  404.         sbuffer[1] = NULL;
  405.     }
  406.  
  407.     if (sbuffer[2] != NULL)
  408.     {
  409.         FreeScreenBuffer (video_screen, sbuffer[2]);
  410.         sbuffer[2] = NULL;
  411.     }
  412.  
  413.     if ((fastaga) || (wpa8))
  414.     {
  415.         if (video_window != NULL)
  416.         {
  417.             ClearPointer (video_window);
  418.             CloseWindow (video_window);
  419.             video_window = NULL;
  420.         }
  421.     }
  422.  
  423.     if (emptypointer != NULL)
  424.     {
  425.         FreeVec (emptypointer);
  426.         emptypointer = NULL;
  427.     }
  428.  
  429.     if (video_screen != NULL)
  430.     {
  431.         CloseScreen (video_screen);
  432.         video_screen = NULL;
  433.     }
  434.  
  435.     for (d = 0; d < 8; d++)
  436.     {
  437.       if (tmp_bm.Planes[d] != NULL)
  438.         {
  439.         FreeRaster (tmp_bm.Planes[d], vid.width, 1);
  440.             tmp_bm.Planes[d] = NULL;
  441.         }
  442.     }
  443.  
  444.     if (smr != NULL)
  445.     {
  446.         FreeAslRequest (smr);
  447.         smr = NULL;
  448.     }
  449.  
  450.     if (msptr != NULL) {
  451.         CloseGraphics (msptr, 1);
  452.         msptr = NULL;
  453.     }
  454.  
  455.     if (AslBase != NULL)
  456.     {
  457.         CloseLibrary (AslBase);
  458.         AslBase = NULL;
  459.     }
  460.  
  461.     if (ChunkyPPCBase != NULL) {
  462.         CloseLibrary (ChunkyPPCBase);
  463.         ChunkyPPCBase = NULL;
  464.     }
  465.  
  466.     if (GfxBase != NULL) {
  467.         CloseLibrary ((struct Library *)GfxBase);
  468.         GfxBase = NULL;
  469.     }
  470.  
  471.     if (IntuitionBase != NULL) {
  472.         CloseLibrary ((struct Library *)IntuitionBase);
  473.         IntuitionBase = NULL;
  474.     }
  475. }
  476.  
  477. /**********************************************************************/
  478. void    VID_Update (vrect_t *rects)
  479. {
  480.   int i, j;
  481.  
  482.     if (is_native_mode)
  483.     {
  484.         if (fastaga)
  485.         {
  486.             while (rects != NULL)
  487.             {
  488.                 for (i = rects->y, j = ((int)(vid_buffer)) + rects->y * vid.width;
  489.                                           i < rects->y + rects->height; i++, j += vid.width)
  490.             ppc_c2p_line (i, j, rp.BitMap, (vid.width + 31) >> 5);
  491.                 rects = rects->pnext;
  492.             }
  493.             if (!nodb)
  494.             {
  495.                 if (ChangeScreenBuffer (video_screen, nextsbuffer))
  496.                 {
  497.               if (nextsbuffer == sbuffer[0])
  498.                 nextsbuffer = sbuffer[1];
  499.               else if (nextsbuffer == sbuffer[1])
  500.                 nextsbuffer = sbuffer[2];
  501.                     else
  502.                         nextsbuffer = sbuffer[0];
  503.                     rp.BitMap = nextsbuffer->sb_BitMap;
  504.                 }
  505.             }
  506.         }
  507.         else
  508.         {
  509.             while (rects != NULL)
  510.             {
  511.                 CallChunkyCopy (&ms, (unsigned char *) next_bm, (void *) vid_buffer,
  512.                                                 PIXFMT_LUT8, 0, 0);
  513.                 if (ms.numbuffers == 2)
  514.                 {
  515.                     if (next_bm == ms.bitmapa)
  516.                         next_bm = ms.bitmapb;
  517.                     else
  518.                         next_bm = ms.bitmapa;
  519.                 }
  520.                 else if (ms.numbuffers == 3)
  521.                 {
  522.                     if (next_bm == ms.bitmapa)
  523.                         next_bm = ms.bitmapb;
  524.                     else if (next_bm == ms.bitmapb)
  525.                         next_bm = ms.bitmapc;
  526.                     else
  527.                         next_bm = ms.bitmapa;
  528.                 }
  529.                 rects = rects->pnext;
  530.             }
  531.             DoubleBuffer (&ms);
  532.         }
  533.     }
  534.     else if (wpa8)
  535.     {
  536.         while (rects != NULL)
  537.         {
  538.             WritePixelArray8 (video_window->RPort, rects->x, rects->y,
  539.                           rects->x + rects->width - 1,
  540.                           rects->y + rects->height - 1,
  541.                           vid_buffer, &temprp);
  542.             rects = rects->pnext;
  543.         }
  544.     }
  545.     else
  546.     {
  547.         while (rects != NULL)
  548.         {
  549.             CallChunkyCopy (&ms, next_sbuf, (void *) vid_buffer, PIXFMT_LUT8, 0, 0);
  550.             if (ms.numbuffers == 2)
  551.             {
  552.                 if (next_sbuf == ms.screen)
  553.                     next_sbuf = ms.screenb;
  554.                 else
  555.                     next_sbuf = ms.screen;
  556.             }
  557.             else if (ms.numbuffers == 3)
  558.             {
  559.                 if (next_sbuf == ms.screen)
  560.                     next_sbuf = ms.screenb;
  561.                 else if (next_sbuf == ms.screenb)
  562.                     next_sbuf = ms.screenc;
  563.                 else
  564.                     next_sbuf = ms.screen;
  565.             }
  566.             rects = rects->pnext;
  567.         }
  568.         DoubleBuffer (&ms);
  569.     }
  570. }
  571.  
  572. /**********************************************************************/
  573. /*
  574. ================
  575. D_BeginDirectRect
  576. ================
  577. */
  578.  
  579. void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
  580. {
  581. }
  582.  
  583. /**********************************************************************/
  584. /*
  585. ================
  586. D_EndDirectRect
  587. ================
  588. */
  589. void D_EndDirectRect (int x, int y, int width, int height)
  590. {
  591. }
  592.  
  593. /**********************************************************************/
  594. void Sys_SendKeyEvents(void)
  595. {
  596.   UWORD code;
  597.     ULONG class;
  598.     WORD mousex, mousey;
  599.   struct IntuiMessage *msg;
  600.   static int xlate[0x68] = {
  601.     '`', '1', '2', '3', '4', '5', '6', '7',
  602.     '8', '9', '0', '-', '=', '\\', 0, '0',
  603.     'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
  604.     'o', 'p', K_F11, K_F12, 0, '0', '2', '3',
  605.     'a', 's', 'd', 'f', 'g', 'h', 'j', 'k',
  606.     'l', ';', '\'', K_ENTER, 0, '4', '5', '6',
  607.     K_SHIFT, 'z', 'x', 'c', 'v', 'b', 'n', 'm',
  608.     ',', '.', '/', 0, '.', '7', '8', '9',
  609.     K_SPACE, K_BACKSPACE, K_TAB, K_ENTER, K_ENTER, K_ESCAPE, K_F11,
  610.     0, 0, 0, '-', 0, K_UPARROW, K_DOWNARROW, K_RIGHTARROW, K_LEFTARROW,
  611.     K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8,
  612.     K_F9, K_F10, '(', ')', '/', '*', '=', K_PAUSE,
  613.     K_SHIFT, K_SHIFT, 0, K_CTRL, K_ALT, K_ALT, 0, K_CTRL
  614.   };
  615.  
  616.     if (video_window !=NULL )
  617.     {
  618.         while ((msg = (struct IntuiMessage *)GetMsg (video_window->UserPort)) != NULL)
  619.         {
  620.       class = msg->Class;
  621.       code = msg->Code;
  622.       mousex = msg->MouseX;
  623.       mousey = msg->MouseY;
  624.       ReplyMsg ((struct Message *)msg);
  625.       switch (class)
  626.             {
  627.         case IDCMP_RAWKEY:
  628.           if ((code & 0x80) != 0)
  629.                     {
  630.             code &= ~0x80;
  631.             if (code < 0x68)
  632.               Key_Event (xlate[code], false);
  633.           }
  634.                     else 
  635.                     {
  636.             if (code < 0x68)
  637.               Key_Event (xlate[code], true);
  638.           }
  639.           break;
  640.         case IDCMP_MOUSEBUTTONS:
  641.                     switch (code)
  642.                     {
  643.                       case IECODE_LBUTTON:
  644.                         Key_Event (K_MOUSE1, true);
  645.                             break;
  646.                     case IECODE_LBUTTON + IECODE_UP_PREFIX:
  647.                       Key_Event (K_MOUSE1, false);
  648.                       break;
  649.                     case IECODE_MBUTTON:
  650.                       Key_Event (K_MOUSE2, true);
  651.                       break;
  652.                     case IECODE_MBUTTON + IECODE_UP_PREFIX:
  653.                       Key_Event (K_MOUSE2, false);
  654.                       break;
  655.                     case IECODE_RBUTTON:
  656.                       Key_Event (K_MOUSE3, true);
  657.                       break;
  658.                     case IECODE_RBUTTON + IECODE_UP_PREFIX:
  659.                       Key_Event (K_MOUSE3, false);
  660.                       break;
  661.                         default:
  662.                             break;
  663.                     }
  664.         case IDCMP_MOUSEMOVE:                                    // Handled in in_amiga.c
  665.           last_mouse[0] = mousex;
  666.           last_mouse[1] = mousey;
  667.                     mousemove = true;
  668.           break;
  669.         default:
  670.           break;
  671.       }
  672.     }
  673.   }
  674. }
  675.  
  676. /**********************************************************************/
  677.